# -*- coding: utf-8 -*-
# @Time    : 2022/6/30 14:12
# @Author  : zyw
# @Email   : panda_kings@163.com
# @File    : paths.py
from common.models import db


class JieDuan(db.Model):
    __tablename__ = 'tb_jieduan'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True, doc='阶段id')
    title = db.Column(db.String(256), doc='阶段名')
    ser_num = db.Column(db.Integer, doc="阶段的序号")
    img = db.Column(db.String(256), doc="阶段的封面")
    desc = db.Column(db.String(256), doc="阶段的描述信息")
    study_time = db.Column(db.Float, doc='学习时长')
    add_num = db.Column(db.Integer, default=0, doc='学些的人数')
    course = db.relationship('Course', secondary='jieduan_course' ,backref='course_jieduan')


# 课程和阶段的中间表
jieduan_course = db.Table(
    'jieduan_course',
    db.Column('course_id', db.Integer, db.ForeignKey("tb_course.id"),primary_key=True),
    db.Column('jieduan_id', db.Integer, db.ForeignKey("tb_jieduan.id"), primary_key=True)
)


